//
//  NSString+RemoveSpaceAndNewline.m
//  WenXianEducation
//
//  Created by  任辰东 on 2020/4/2.
//  Copyright © 2020 JSY. All rights reserved.
//

#import "NSString+RemoveSpaceAndNewline.h"

@implementation NSString (RemoveSpaceAndNewline)

- (NSString *)removeSpaceAndNewline:(StringRemoveStyle)style
{
    
    if (style == StringRemoveStyleBothEnds) {
        
        NSString *temp = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
           
           
        NSString *text = [temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet ]];
           
        return text;
        
    }else{
        
        NSString *temp = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
        
        temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];
        
        temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];
        
        return temp;
    }

}
@end
